package com.dhj.lambdaTest;

import java.util.function.Function;

public class Demo5 {

    public static void main(String[] args) {
        Integer len = typeConvert(new Function<String, Integer>() {
            @Override
            public Integer apply(String s) {
                return s.length();
            }
        });
        System.out.println("====== len is "+len);

        String s = typeConvert(str -> str + "---end.");
        System.out.println(s);

        Integer len2 = typeConvert(s1 -> s1.length());
        System.out.println(len2);

    }

    public static <R> R typeConvert(Function<String, R> function){
        String str = "12345";
        R result = function.apply(str);
        return result;
    }

}
